package com.as.dao;

import java.util.List;

import com.as.base.BaseDaoImpl;
import com.as.entity.Question;

public class QuestionDaoImpl extends BaseDaoImpl<Question> implements QuestionDao{

	@Override
	public List<Question> getWrong(String userid,int state) {
		String sql = "FROM Question q WHERE q.ansid =? AND q.state =?";
		if(userid==null){
			return null;
		}
		return getSession().createQuery(sql)
				.setParameter(0, userid)
				.setParameter(1, state)
				.list();
	}

	@Override
	public List<Question> getPageWrong(String userid, int state,
			int pageNow,int pageSize) {
		String sql="select * from question q where q.ansid =? AND q.state =? limit "
			+((pageNow-1)*pageSize)+","+pageSize;
		return getSession().createSQLQuery(sql)
				.setParameter(0, userid)
				.setParameter(1, state)
				.list();
	}

}
